package com.johnny.springai.flightbooking.service;

import com.johnny.springai.flightbooking.module.BookingDetail;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ToolsService {

    @Autowired
    private FlightBookingService flightBookingService;

    /**
     * 模拟退票功能
     * @param ticketNumber
     * @param name
     * @return
     */
    @Tool(description = "退票/取消预定，调用前先查询航班")
    public String cancelTicket(
            //@ToolParam 告诉大模型参数的用途
            @ToolParam(description = "预定号，可以是纯数字") String ticketNumber,
            @ToolParam(description = "姓名（必须是真实姓名，严谨用其他信息代替，如缺失请传null）") String name) {

        flightBookingService.cancelBooking(ticketNumber, name);
        return "退票成功";
    }

    @Tool(description = "获取航班信息")
    public BookingDetail getFlightInfo(
            @ToolParam(description = "预定号，可以是纯数字") String ticketNumber,
            @ToolParam(description = "姓名（必须是真实姓名，严谨用其他信息代替，如缺失请传null）") String name) {
        return flightBookingService.getBookingDetails(ticketNumber, name);
    }

}
